/*
 * Copyright (c) 2024 Black Sesame Technologies
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef _DAL_RTICONNEXTDDS_STATUS_CONVERTER_HPP_
#define _DAL_RTICONNEXTDDS_STATUS_CONVERTER_HPP_

#include "ndds/dds_c/dds_c_domain.h"
#include "ndds/dds_c/dds_c_topic.h"
#include "ndds/dds_c/dds_c_subscription.h"
#include "ndds/dds_c/dds_c_publication.h"
#include "dal/status.h"
#include "dal/ret_type.h"

class StatusConverter
{
protected:
    StatusConverter();
    static StatusConverter* singleton_;

public:
    StatusConverter(StatusConverter& other) = delete;
    void operator=(const StatusConverter&) = delete;
    static StatusConverter* GetInstance();

    dal_ret_t
    ConvertInconsistentTopicStatusFromRtiddsToDal(const DDS_InconsistentTopicStatus* r_status,
                                                   dal_inconsistent_topic_status_t* d_status);

    dal_ret_t ConvertSampleLostStatusFromRtiddsToDal(const DDS_SampleLostStatus* r_status,
                                                      dal_sample_lost_status_t* d_status);

    dal_ret_t ConvertSampleRejectedStatusFromRtiddsToDal(const DDS_SampleRejectedStatus* r_status,
                                                          dal_sample_rejected_status_t* d_status);

    dal_ret_t ConvertLivelinessLostStatusFromRtiddsToDal(const DDS_LivelinessLostStatus* r_status,
                                                          dal_liveliness_lost_status_t* d_status);

    dal_ret_t
    ConvertLivelinessChangedStatusFromRtiddsToDal(const DDS_LivelinessChangedStatus* r_status,
                                                   dal_liveliness_changed_status_t* d_status);

    dal_ret_t ConvertOfferedDeadlineMissedStatusFromRtiddsToDal(
        const DDS_OfferedDeadlineMissedStatus* r_status, dal_offered_deadline_missed_status_t* d_status);

    dal_ret_t ConvertRequestedDeadlineMissedStatusFromRtiddsToDal(
        const DDS_RequestedDeadlineMissedStatus* r_status,
        dal_requested_deadline_missed_status_t* d_status);

    dal_ret_t ConvertOfferedIncompatibleQosStatusFromRtiddsToDal(
        const DDS_OfferedIncompatibleQosStatus* r_status,
        dal_offered_incompatible_qos_status_t* d_status);

    dal_ret_t ConvertRequestedIncompatibleQosStatusFromRtiddsToDal(
        const DDS_RequestedIncompatibleQosStatus* r_status,
        dal_requested_incompatible_qos_status_t* d_status);

    dal_ret_t
    ConvertPublicationMatchedStatusFromRtiddsToDal(const DDS_PublicationMatchedStatus* r_status,
                                                    dal_publication_matched_status_t* d_status);

    dal_ret_t
    ConvertSubscriptionMatchedStatusFromRtiddsToDal(const DDS_SubscriptionMatchedStatus* r_status,
                                                     dal_subscription_matched_status_t* d_status);
};

#endif  // _DAL_RTICONNEXTDDS_STATUS_CONVERTER_HPP_
